<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改学生')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-student-edit" th:object="${manageStudent}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">学号：</label>
                <div class="col-sm-8">
                    <input name="stuno" th:field="*{stuno}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">学生姓名：</label>
                <div class="col-sm-8">
                    <input name="stuname" th:field="*{stuname}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">学生性别：</label>
                <div class="col-sm-8">
                    <select name="stusex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{stusex}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">手机号码：</label>
                <div class="col-sm-8">
                    <input name="phonenumber" th:field="*{phonenumber}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">班级：</label>
                <div class="col-sm-8">
                    <select name="classid" id="classid" class="form-control m-b" required>
                        <option th:each="cls : ${classes}" th:text="${cls.gradeNum} + '年' + ${cls.classNum} + '班'" th:value="${cls.id}" th:field="*{classid}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box">
                        <input type="radio" name="status" id="status-1" value="1" th:field="*{status}">
                        <label for="status-1">正常</label>
                    </div>
                    <div class="radio-box">
                        <input type="radio" name="status" id="status-2" value="0" th:field="*{status}">
                        <label for="status-2">停用</label>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/student";
        $("#form-student-edit").validate({
            onkeyup: false,
            rules:{
                classCode:{
                    maxlength:60,
                    remote: {
                        url: prefix + "/checkStunoUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "id": function() {
                                return $("input[name='id']").val();
                            },
                            "stuno" : function() {
                                return $.common.trim($("input[name='stuno']").val());
                            }
                        }
                    }
                },
                stuno:{
                    maxlength:20,
                    digits:true
                },
                stuname:{
                    maxlength:50
                },
                phonenumber:{
                    isPhone:true
                },
            },
            messages: {
                "stuno": {
                    remote: "学号已存在！"
                }
            },
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-student-edit').serialize());
            }
        }
    </script>
</body>
</html>